import {
  iosProvinces,
  iosCitys,
  iosCountys
} from "@/components/share/area/areaData_v2.js";

export default function(Vue) {
  //省份
  Vue.filter("province", function(val) {
    var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
    if (reg.test(val)) {
      return val;
    }
    if (val && val != null && val != "undefined") {
      for (var i = 0; i < iosProvinces.length; i++) {
        if (iosProvinces[i].id == val) {
          return iosProvinces[i].value;
        }
      }
    }
  });
  //市份
  Vue.filter("city", function(val) {
    var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
    if (reg.test(val)) {
      return val;
    }
    if (val && val != null && val != "undefined") {
      for (var i = 0; i < iosCitys.length; i++) {
        if (iosCitys[i].id == val) {
          return iosCitys[i].value;
        }
      }
    }
  });
  //区
  Vue.filter("district", function(val) {
    var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
    if (reg.test(val)) {
      return val;
    }
    if (val && val != null && val != "undefined") {
      for (var i = 0; i < iosCountys.length; i++) {
        if (iosCountys[i].id == val) {
          return iosCountys[i].value;
        }
      }
    }
  });
  //省市区反向过滤
  //省份
  Vue.filter("TextProvince", function(val) {
    if (val && val != null && val != "undefined") {
      for (var i = 0; i < iosProvinces.length; i++) {
        if (iosProvinces[i].value == val) {
          return iosProvinces[i].id;
        }
      }
    }
  });
  //市份
  Vue.filter("TextCity", function(val) {
    if (val && val != null && val != "undefined") {
      for (var i = 0; i < iosCitys.length; i++) {
        if (iosCitys[i].value == val) {
          return iosCitys[i].id;
        }
      }
    }
  });
  //区
  Vue.filter("TextDistrict", function(val) {
    if (val && val != null && val != "undefined") {
      for (var i = 0; i < iosCountys.length; i++) {
        if (iosCountys[i].value == val) {
          return iosCountys[i].id;
        }
      }
    }
  });
  //加班申请审批状态
  Vue.filter("overtimeDataStatus", function(val) {
    switch(val){
      case "1":
        return '待提交';
        break;
      case "2":
        return '待直属上级审批';
        break;
      case "3":
        return '待事业部副总经理审批';
        break;
      case "4":
        return '待事业部总经理审批';
        break;
      case "5":
        return '待人力资源审批';
        break;
      case "6":
        return '审批通过';
        break;
    }
  });
  //外出申请审批状态
  Vue.filter("egressDataStatus", function(val) {
    switch(val){
      case "1":
        return '待提交';
        break;
      case "2":
        return '待直属上级审批';
        break;
      case "3":
        return '待人力资源审批';
        break;
      case "4":
        return '审批通过';
        break;
    }
  });
  //出差申请审批状态
  Vue.filter("bizTripDataStatus", function(val) {
    switch(val){
      case "1":
        return '待提交';
        break;
      case "2":
        return '待直属上级审批';
        break;
      case "3":
        return '待事业部副总经理审批';
        break;
      case "4":
        return '待事业部总经理审批';
        break;
      case "5":
        return '待人力资源审批';
        break;
      case "6":
        return '待财务部确认';
        break;
      case "7":
        return '审批通过';
        break;
    }
  });
  //差旅报销申请审批状态
  Vue.filter("expenseAccountDataStatus", function(val) {
    switch(val){
      case "1":
        return '待提交';
        break;
      case "2":
        return '待事业部副总经理审批';
        break;
      case "3":
        return '待事业部总经理审批';
        break;
      case "4":
        return '待总账会计审批';
        break;
      case "5":
        return '待出纳审批';
        break;
      case "6":
        return '待财务经理审批';
        break;
      case "7":
        return '待总经理审批';
        break;
      case "8":
        return '审批通过';
        break;
    }
  });
  //图片url转换
  Vue.filter("fileImg",function(val){
    let vals = val.replace(/\\/g, "/");
    return process.env.Upload_Files + vals;
  });
  // 时间轴
  Vue.filter("timeshort", function(value) {
    var time =value ? value.replace("T", " ") : "";
    return time.substr(0,(time.length-3))
    // .substr(0,(time.length-8));
  });
  Vue.filter("timeReplaceT",function(value){
    var time =value ? value.replace("T", " ") : "";
    return time;
  })
  Vue.filter("leavetype",function(val){

    switch(val){
      case "1":
        return '年假';
        break;
      case "2":
        return '事假';
        break;
      case "3":
        return '病假';
        break;
      case "4":
        return '调休假';
        break;
      case "5":
        return '产假/陪产假';
        break;
      case "6":
        return '婚假';
        break;
      case "7":
        return '丧假';
        break;
    }
  })
}
